package com.ncmmall.application.business.bankcard;

import com.ncmmall.domain.business.bankcard.BankCard;
import com.ncmmall.domain.business.bankcard.BankCardRepository;
import com.ncmmall.querychannel.service.QueryChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.sql.Timestamp;

/**
 * 银行卡
 *
 * @author likaikai
 * @date 2019-07-15 16:28
 */
@Service
@Transactional
public class BankCardApplication {

    @Autowired
    private BankCardRepository bankCardRepository;

    @Autowired
    private QueryChannelService queryChannelService;

    /**
     * 添加银行卡
     *
     * @param bankCard
     */
    public void create(BankCard bankCard) {
        bankCard.setCreateTime(new Timestamp(System.currentTimeMillis()));
        bankCardRepository.save(bankCard);
    }

    /**
     * 删除银行卡
     *
     * @param bankCard
     */
    public void remove(BankCard bankCard) {
        bankCardRepository.delete(bankCard);
    }

    /**
     * 修改银行卡信息
     *
     * @param bankCard
     * @param params
     */
    public void modify(BankCard bankCard, BankCard params) {

        bankCard.setAccountName(params.getAccountName());
        bankCard.setMobile(params.getMobile());
        bankCard.setBankName(params.getBankName());
        bankCard.setBankCardNo(params.getBankCardNo());
        bankCard.setBankProvince(params.getBankProvince());
        bankCard.setBankCity(params.getBankCity());
        bankCard.setBankSubBranch(params.getBankSubBranch());

        bankCardRepository.save(bankCard);

    }

}
